<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>文字逐渐显示</title>
</head>
<body>
<div id="app">
    <h1 v-bind:style="{opacity}" id="message">西安欢迎您！</h1>
</div>

<script src="../../../../js/vue.global.js"></script>
<script>
    const app = Vue.createApp({
        data() {
            return {
                opacity: 0,
            }
        },
        methods: {},
        mounted() {
            /*setInterval(
                () => {
                    this.opacity += 0.02
                    if (this.opacity > 1) {
                        this.opacity = 0
                    }
                },
                500
            )*/

            // console.log(this);
            let that = this
            setInterval(
                function ()  {
                    console.log(that);
                    that.opacity += 0.02
                    if (that.opacity > 1) {
                        that.opacity = 0
                    }
                },
                500
            )
        }
    })

    app.mount("#app")
</script>
</body>
</html>